home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / OOPTUT34.ZIP / DIALOG.TXT < prev    next >
Text File  |  1992-09-07  |  3KB  |  75 lines

  1.  
  2.                                DIALOG BOXES.
  3.                                -------------
  4.  
  5.  A dialog box is a special kind of window, with the type TDialog a
  6.  descendant of TWindow.  It differs from a window in that it is grey, it is
  7.  neither resizable nor zoomable and it has no window number.  Usually a
  8.  dialog box, when opened, is the only thing active and it is then said to be
  9.  the 'modal view'.  If a dialog box object is 'inserted' into the desktop it
  10.  is non-modal, so to create a modal dialog box it must be 'executed' by
  11.  calling the DeskTop^.ExecView function.  Programs TVGUID11.PAS and
  12.  TVGUID12.PAS illustrate non-modal and modal dialog boxes respectively.
  13.  
  14.  A meaningful dialog box must have 'controls', such as an object of type
  15.  TButton, which acts like a status line item.  It is a coloured region with
  16.  a text label, which will generate a command when clicked.  Most dialog
  17.  boxes have at least two buttons, 'OK' and 'Cancel', which respectively
  18.  accept or cancel any changes made within the dialog box.  The Dialogs unit
  19.  defines five standard dialog commands that can be bound to a TButton: cmOK,
  20.  cmCancel, cmYes, cmNo and cmDefault.  Buttons, however, can be used to
  21.  generate commands specific to any application.
  22.  
  23.  Creating a button requires four parameters for the Init constructor:
  24.  
  25.   1. the region the button will cover (allowing for the shadow)
  26.   2. the text that will appear on the button
  27.   3. the command to be bound to the button
  28.   4. a button flag indicating the type of button (normal or default, which
  29.                                                  responds to the ENTER key)
  30.  
  31.  Program TVGUID13.PAS illustrates the statements used, including:
  32.  
  33.       ...
  34.       WITH Dialog^ DO
  35.       BEGIN
  36.         R.Assign(15, 10, 25, 12);
  37.         Insert(New(PButton, Init(R, '~O~K', cmOK, bfDefault)));
  38.         ...
  39.       END;
  40.       Control := DeskTop^.ExecView(Dialog);
  41.       ...
  42.  
  43.  To allow a user to choose among options, 'check boxes' and 'radio buttons'
  44.  are also provided in dialog boxes.  Check boxes allow multiple selection,
  45.  whereas radio buttons allow one only choice.  They are both descendants of
  46.  the object type TCluster.  Many of the dialog boxes displayed by the
  47.  Options menu in the Turbo Pascal IDE feature this kind of cluster control.
  48.  
  49.  The code for CheckBoxes includes:
  50.  
  51.      B := New(PCheckBoxes, Init(R, NewSItem...
  52.  
  53.  where the NewSItem function is in DIALOG.TPU, is shown on page 360 of the
  54.  Guide and returns a type PSItem, a pointer to a record type TSItem,
  55.  required by the constructor Init, inherited from TCluster (p 218).
  56.  
  57.  The controls can be labelled using another control called the TLabel, which
  58.  can be inserted, allocated and initialized with the code:
  59.       Insert(New(PLabel, Init(R, 'LabelName', B)));
  60.  
  61.  Full details of labelled controls are given on page 55 of the Guide and are
  62.  illustrated in program TVGUID14.PAS.
  63.  
  64.  An 'input line' for editing string input can also be added to a dialog box.
  65.  TInputLine is the object type used, with the methods SetData and GetData
  66.  used to copy data to and from a view.  See pages 55-59 of the Guide for
  67.  details and programs TVGUID15.PAS and TVGUID16.PAS for illustrations.
  68.  
  69.  Standard dialog boxes are contained in the StdDlg unit (p 62).
  70.  
  71.  
  72.  DIALOG.WR1
  73.  DIALOG.TXT
  74.  22.3.91
  75.